/**
 * <pre>
 * -
 * Author : J.L.Zhou
 * E-Mail : 2233875735@qq.com
 * Tel : 151 1104 7708
 * Date : 2021-04-01 10:41
 * Version : 1.0
 * Copyright 2021 jlzhou.top Inc. All rights reserved.
 * Warning: this content is only for internal circulation of the company.
 *          It is forbidden to divulge it or use it for other commercial purposes.
 * </pre>
 **/
public class Person {

  public static void main(String[] args) {
    Person p1 = new Person("张三",18,'男');
    p1.setName("张三丰");
    System.out.println(p1);
    Person p2 = new Person("李四",19,'女');
    System.out.println(p2);
    Person p3 = new Person();
    System.out.println(p3);
    Person p4 = new Person("王五");
    System.out.println(p4);
  }

  String name;
  int age;
  char sex;

  /**
   * 构造方法
   */
  public Person(){
    this("匿名");
    this.setAge(1);
//    this("匿名");//使用this调用构造方法只能是在构造方法的第一行
  }

//  public Person(String name1,int age1,char sex1){
//    name = name1;
//    age = age1;
//    sex = sex1;
//  }

//  public Person(String name,int age,char sex){
//    this.name = name;
//    this.age = age;
//    this.sex = sex;
//  }

  //代码生成


  public Person(String name, int age, char sex) {
    this.name = name;
    this.age = age;
    this.sex = sex;
  }

  public Person(String name) {
    this.name = name;
    this.setAge(18);
    setSex('男');
  }

  /**
   * 普通方法
   * 强烈不推荐
   */
//  public void Person(){
//
//  }

//  public String toString(){
//    return "Person:name="+name+",age="+age+",sex="+sex;
//  }

  public String getName(){
    return this.name;
  }

  public void setName(String name){
    this.name = name;
  }

  public int getAge() {
    return age;
  }

  public void setAge(int age) {
    this.age = age;
  }

  public char getSex() {
    return sex;
  }

  public void setSex(char sex) {
    this.sex = sex;
  }

  @Override
  public String toString() {
    return "Person{" +
        "name='" + name + '\'' +
        ", age=" + age +
        ", sex=" + sex +
        '}';
  }
}
